<Window x:Class="ScrumSprintMonitor.ConfigEditor.Views.ConfigurationView.ConfigurationWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:ScrumSprintMonitor.ConfigEditor"
		xmlns:ConfigurationView="clr-namespace:ScrumSprintMonitor.ConfigEditor.Views.ConfigurationView"
		xmlns:converters="clr-namespace:ScrumSprintMonitor.ConfigEditor.Converters"
		xmlns:Behaviors="clr-namespace:ScrumSprintMonitor.UI.Wpf.Behaviors;assembly=ScrumSprintMonitor.UI.Wpf"
		xmlns:Behaviors1="clr-namespace:WpfWatermarkTextBox.Behaviors"
		Title="Configure Scrum Sprint Monitor"
		Background="Gray"
		Width="600" WindowStartupLocation="CenterScreen"
		Loaded="OnWindowLoaded" Activated="OnWindowActivated" MouseLeftButtonDown="OnWindowMouseLeftButtonDown">

	<Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="pack://application:,,,/ScrumSprintMonitor.UI.Wpf;component/Styles/FormResourceDictionary.xaml" />
			</ResourceDictionary.MergedDictionaries>

			<local:XamlServiceLocator x:Key="serviceLocator" />

			<converters:NegatedValueConverter x:Key="NegatedValueConverter" />

			<Style x:Key="watermarkLabelStyle">
				<Setter Property="TextBlock.Foreground" Value="{x:Static SystemColors.ControlDarkBrush}" />
				<Setter Property="FrameworkElement.Opacity" Value="0.8" />
				<Setter Property="TextBlock.FontSize" Value="12" />
				<Setter Property="TextBlock.FontStyle" Value="Italic" />
				<Setter Property="TextBlock.Margin" Value="8,4,4,4" />
			</Style>

			<Style x:Key="BaseTimePickerStyle" TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextBoxStyle}">
				<Setter Property="Margin" Value="3" />
				<Setter Property="HorizontalAlignment" Value="Stretch" />
				<Setter Property="HorizontalContentAlignment" Value="Left" />
			</Style>
		</ResourceDictionary>
	</Window.Resources>

	<Window.Style>
		<StaticResource ResourceKey="DefaultChrome" />
	</Window.Style>

	<Grid DataContext="{Binding Path=ConfigurationViewModel, Source={StaticResource serviceLocator}}"
		  Behaviors:BusyIndicatorBehavior.BusyState="{Binding IsBusy}"
		  Behaviors:BusyIndicatorBehavior.TargetVisual="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}}"
		  Behaviors:BusyIndicatorBehavior.AddMargins="True">
		<DockPanel>
			<Grid DockPanel.Dock="Top">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>

				<Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="0" Content="_Team Foundation Server:" Target="{Binding ElementName=tfsServerNameComboBox}" />
				<ComboBox Grid.Column="1" Grid.Row="0" Margin="0,3" ItemsSource="{Binding Path=AvailableTfsServers.Keys}" SelectedItem="{Binding Path=TfsServerName}" x:Name="tfsServerNameComboBox" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" ToolTip="Choose the Team Foundation Server you want to connect to. This combobox only lists servers that have been previously connected to through Team Explorer on this machine." />

				<Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="1" Content="_Credentials:" Target="{Binding ElementName=tfsServerUserNameTextBox}" />
				<Grid Grid.Column="1" Grid.Row="1">
					<Grid.ColumnDefinitions>
						<ColumnDefinition />
						<ColumnDefinition />
					</Grid.ColumnDefinitions>

					<TextBox Margin="0,3,3,3" Height="21"
							 Behaviors1:WatermarkTextBoxBehavior.EnableWatermark="True"
							 Behaviors1:WatermarkTextBoxBehavior.Label="Optionally enter TFS user name"
							 Behaviors1:WatermarkTextBoxBehavior.LabelStyle="{StaticResource watermarkLabelStyle}"
							 Text="{Binding Path=TfsServerUserName}" x:Name="tfsServerUserNameTextBox" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" />

					<PasswordBox Grid.Column="1" Margin="0,3" Height="21"
								 x:Name="tfsServerPasswordTextBox"
								 Behaviors1:WatermarkPasswordBoxBehavior.EnableWatermark="True"
								 Behaviors1:WatermarkPasswordBoxBehavior.Label="Optionally enter TFS password"
								 Behaviors1:WatermarkPasswordBoxBehavior.LabelStyle="{StaticResource watermarkLabelStyle}"
								 ConfigurationView:PasswordHelper.Attach="True"
								 ConfigurationView:PasswordHelper.Password="{Binding TfsServerPassword, Mode=TwoWay}" />
				</Grid>

				<ContentControl Grid.Row="2" Grid.ColumnSpan="2" ContentTemplate="{StaticResource Separator}" IsTabStop="False" Focusable="False">
					<ContentControl.Content>
						<Label Style="{StaticResource LabelStyle}">
							<TextBlock>
								<Bold>
									1)
									<Span />
								</Bold>
								Current Sprint
							</TextBlock>
						</Label>
					</ContentControl.Content>
				</ContentControl>

				<Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="3" Content="_Configuration File:" Target="{Binding ElementName=configurationFileTextBox}" />
				<Grid Grid.Column="1" Grid.Row="3">
					<Grid.ColumnDefinitions>
						<ColumnDefinition />
						<ColumnDefinition Width="Auto" />
					</Grid.ColumnDefinitions>
					<TextBox x:Name="configurationFileTextBox" Style="{StaticResource TextBoxStyle}" Grid.Column="0" Text="{Binding Path=ConfigurationFilePath}" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" ToolTip="Enter a path to the file (new or existing) that will be used to store the sprint configuration." />
					<Button Command="{Binding BrowseSprintConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Column="1" Content="..." Padding="6,0" Margin="0,2" IsEnabled="{Binding IsConfigurationWritable}" />
				</Grid>
				<Button Command="{Binding EditSprintConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Row="4" Grid.ColumnSpan="2" HorizontalAlignment="Right" Content="Edit _Sprint Configuration..." Padding="6" Margin="0,2" />

				<ContentControl Grid.Row="5" Grid.ColumnSpan="2" ContentTemplate="{StaticResource Separator}" IsTabStop="False" Focusable="False">
					<ContentControl.Content>
						<Label Style="{StaticResource LabelStyle}">
							<TextBlock>
								<Bold>
									2)
									<Span />
								</Bold>
								Team Members
							</TextBlock>
						</Label>
					</ContentControl.Content>
				</ContentControl>

				<Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="6" Content="Configuration File:" Target="{Binding ElementName=teamMembersConfigurationTextBox}" />
				<Grid Grid.Column="1" Grid.Row="6">
					<Grid.ColumnDefinitions>
						<ColumnDefinition />
						<ColumnDefinition Width="Auto" />
					</Grid.ColumnDefinitions>
					<TextBox x:Name="teamMembersConfigurationTextBox" Style="{StaticResource TextBoxStyle}" Grid.Column="0" Text="{Binding Path=TeamMembersConfigurationFilePath}" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" ToolTip="Enter a path to the file (new or existing) that will be used to store the team members configuration." />
					<Button Command="{Binding BrowseTeamMembersConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Column="2" Content="..." Padding="6,0" Margin="0,2" IsEnabled="{Binding IsConfigurationWritable}" />
				</Grid>
				<StackPanel Orientation="Horizontal" Grid.Row="7" Grid.ColumnSpan="2" HorizontalAlignment="Right">
					<Button Command="{Binding GenerateTeamMembersConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Content="_Generate file from current sprint..." Padding="6" Margin="0,2,6,2" ToolTip="Use this button to generate a base team-info.xml file with the team members found in the sprint query defined in step 1. Afterwards, you can use Microsoft Excel to fine tune the data in that file." />
					<Button Command="{Binding EditTeamMembersConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Content="Edit in Microsoft E_xcel 2007..." Padding="6" Margin="0,2" />
				</StackPanel>

				<ContentControl Grid.Row="8" Grid.ColumnSpan="2" ContentTemplate="{StaticResource Separator}" IsTabStop="False" Focusable="False">
					<ContentControl.Content>
						<Label Style="{StaticResource LabelStyle}">
							<TextBlock>
								<Bold>
									3)
									<Span />
								</Bold>
								General Presentation Options
							</TextBlock>
						</Label>
					</ContentControl.Content>
				</ContentControl>

				<Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="9" Content="Configuration File:" Target="{Binding ElementName=presentationConfigurationTextBox}" />
				<Grid Grid.Column="1" Grid.Row="9">
					<Grid.ColumnDefinitions>
						<ColumnDefinition />
						<ColumnDefinition Width="Auto" />
					</Grid.ColumnDefinitions>
					<TextBox x:Name="presentationConfigurationTextBox" Style="{StaticResource TextBoxStyle}" Grid.Column="0" Text="{Binding Path=PresentationConfigurationFilePath}" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" ToolTip="Enter a path to the file (new or existing) that will be used to store the UI presentation configuration." />
					<Button Command="{Binding BrowsePresentationConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Column="2" Content="..." Padding="6,0" Margin="0,2" IsEnabled="{Binding IsConfigurationWritable}" />
				</Grid>
				<Button Command="{Binding EditPresentationConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Row="10" Grid.ColumnSpan="2" HorizontalAlignment="Right" Content="Edit _General Options..." Padding="6" Margin="0,2" />

				<Expander Grid.Row="11" Grid.ColumnSpan="2" Header="_Power Saving" Foreground="White" HeaderTemplate="{StaticResource ExpanderSeparator}">
					<StackPanel>
						<!--<Grid IsEnabled="{Binding CanEditMachineWakeUpSetting}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition MaxWidth="100" Width="*" />
							</Grid.ColumnDefinitions>

							<CheckBox x:Name="wakeUpMachineCheckBox" IsChecked="{Binding Path=WakeUpMachine}" Margin="6" IsEnabled="{Binding IsConfigurationWritable}">
								<Label Style="{StaticResource LabelStyle}" Content="Wake up computer at" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=wakeUpMachineCheckBox}" />
							</CheckBox>
							<TextBox Grid.Column="1" IsEnabled="{Binding Path=WakeUpMachine}" Style="{StaticResource BaseTimePickerStyle}" Text="{Binding Path=TimeOfDayToWakeUpMachine, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" />
						</Grid>-->
						<Grid IsEnabled="{Binding CanEditSuspendMachineSetting}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition MaxWidth="100" Width="*" />
							</Grid.ColumnDefinitions>

							<CheckBox x:Name="suspendMachineCheckBox" IsChecked="{Binding Path=SuspendMachine}" Margin="6" IsEnabled="{Binding IsConfigurationWritable}">
								<Label Style="{StaticResource LabelStyle}" Content="Suspend computer at" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=suspendMachineCheckBox}" />
							</CheckBox>
							<TextBox Grid.Column="1" IsEnabled="{Binding Path=SuspendMachine}" Style="{StaticResource BaseTimePickerStyle}" Text="{Binding Path=TimeOfDayToSuspendMachine, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" />
						</Grid>

						<TextBlock Margin="3">To resume the machine, you may want to use a free software such as Dennis Babkin's <Hyperlink NavigateUri="http://www.dennisbabkin.com/php/download.php?what=WOSB" Foreground="#FF4EE4FF" RequestNavigate="OnHyperlinkRequestNavigate">WakeupOnStandBy</Hyperlink>.</TextBlock>
					</StackPanel>
				</Expander>

				<Expander Grid.Row="12" Grid.ColumnSpan="2" Header="_Outlook Integration" Foreground="White" HeaderTemplate="{StaticResource ExpanderSeparator}">
					<StackPanel>
						<CheckBox x:Name="enableOutlookIntegrationCheckBox" IsChecked="{Binding Path=EnableOutlookIntegration}" Margin="6" IsEnabled="{Binding IsConfigurationWritable}">
							<Label Style="{StaticResource LabelStyle}" Content="Enable Outlook integration for _Free/Busy information" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=enableOutlookIntegrationCheckBox}" />
						</CheckBox>
						<CheckBox x:Name="considerOutlookTentativeAsFreeTimeCheckBox" IsChecked="{Binding Path=ConsiderOutlookTentativeAsFreeTime}" IsEnabled="{Binding IsConsiderOutlookTentativeAsFreeTimeEnabled}" Margin="6">
							<Label Style="{StaticResource LabelStyle}" Content="Consider 'Tentative' _appointments to be free time" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=considerOutlookTentativeAsFreeTimeCheckBox}" />
						</CheckBox>
					</StackPanel>
				</Expander>

				<Expander Grid.Row="13" Grid.ColumnSpan="2" Header="_Miscellaneous" Foreground="White" HeaderTemplate="{StaticResource ExpanderSeparator}">
					<StackPanel>
						<CheckBox x:Name="inPlanningModeCheckBox" IsChecked="{Binding Path=InPlanningMode}" Margin="6" IsEnabled="{Binding IsConfigurationWritable}">
							<Label Style="{StaticResource LabelStyle}" Content="_Planning Mode" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=inPlanningModeCheckBox}" />
						</CheckBox>

						<CheckBox x:Name="reportUnestimatedSprintBacklogItemsCheckBox" IsChecked="{Binding Path=ReportUnestimatedSprintBacklogItems}" Margin="6" IsEnabled="{Binding IsConfigurationWritable}">
							<Label Style="{StaticResource LabelStyle}" Content="Report _unestimated sprint backlog items" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=reportUnestimatedSprintBacklogItemsCheckBox}" />
						</CheckBox>

						<CheckBox x:Name="showBurndownChartCheckBox" IsChecked="{Binding Path=ShowBurndownChart}" Margin="6" IsEnabled="{Binding IsShowBurndownChartEnabled}" ToolTip="NOTE: Turning this option on can cause hundreds of small asynchronous requests to the server, as the burndown chart is initially built.">
							<Label Style="{StaticResource LabelStyle}" Content="Show sprint _burndown charts" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=showBurndownChartCheckBox}" />
						</CheckBox>

						<CheckBox x:Name="useMultipleMonitorsCheckBox" IsChecked="{Binding Path=UseMultipleMonitors}" Margin="6" ToolTip="Turning this option on allows the use of all available monitors, instead of just the primary one.">
							<Label Style="{StaticResource LabelStyle}" Content="Allow use of _multiple monitors" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=useMultipleMonitorsCheckBox}" />
						</CheckBox>

						<CheckBox x:Name="optInCeipCheckBox" IsChecked="{Binding Path=OptInCEIP}" Margin="6" ToolTip="Turning this option on allows the software to periodically send data to CodePlex.com regarding feature usage on the software, providing better insight for future improvements (no identifiable or sensitive data is transmitted).">
							<Label Style="{StaticResource LabelStyle}" Content="Participate in the Customer Experience Improvement Program" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=optInCeipCheckBox}" />
						</CheckBox>
					</StackPanel>
				</Expander>

                <Image Source="Donate.png" StretchDirection="DownOnly" Stretch="None" Grid.Row="14" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="3" MouseLeftButtonDown="OnDonateButtonMouseLeftButtonDown" KeyDown="OnDonateButtonKeyDown" Focusable="True" />
			</Grid>

			<Grid DockPanel.Dock="Bottom">
				<Button Command="{Binding ViewLogFileCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0,0,6,0" Padding="16,4" Content="View _Log File..." MinWidth="72" />

				<StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Bottom" Margin="0,12,0,0">
					<Button Command="{Binding OkCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Margin="6,0,0,0" Padding="16,4" IsDefault="True" Content="O_K" MinWidth="72" />
					<Button Command="{Binding CancelCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Margin="6,0,0,0" Padding="16,4" IsCancel="True" Content="Cancel" MinWidth="72" />
					<Button Command="{Binding HelpCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Margin="6,0,0,0" Padding="16,4" Content="_Help" MinWidth="72" />
				</StackPanel>
			</Grid>
		</DockPanel>
	</Grid>
</Window>